<template>
  <div>{{ $var }}</div>
  <div>{{ $filter('全局方法：') }}</div>
  <div>{{ varProvide }}</div>
</template>

<script setup lang="ts">
// 法一： getCurrentInstance
import { getCurrentInstance } from 'vue';
const instance = getCurrentInstance();
console.log('setup访问全局属性：', instance?.proxy?.$var);
console.log('setup 访问全局方法：', instance?.proxy?.$filter('setup'));

// 法二：provide
import { inject } from 'vue';
const varProvide = inject('$varProvide');
console.log(varProvide);
</script>

<style lang="scss" scoped></style>
